
ss();
function ss(){
  $(this).html('');
  for (var i = 0;i<cityArr.length;i++){
    var option = document.createElement('option');
    option.innerText = cityArr[i].name;
    $('#shi').append(option);
  }
}
  $('.tianjia').click(function (){
    var popBox = document.getElementById('popBox');
    var popLayer=document.getElementById('popLayer');
    popBox.style.display  = 'block';
    popLayer.style.display = 'block';
  })
  $('#qued1').click(function (){
    var id =$('#id')[0].value;
    var name =$('#name')[0].value;
    var xiaoz = $('#xiaoz')[0].value;
    var luru = $('#luren')[0].value;
    var cityN =$('#cityNode')[0].value;
    var yonghuArr = [{"id":id,"name":name,"principal":xiaoz,"startTime":luru,"cityNode":cityN}];
    schoolArr.push(yonghuArr);
    var num = 0;
    for (var j = 0;j<schoolArr.length;j++){
        $("#fu").append(
          `<tr id=${'tr' + num}>
           <td class="d1"><input type="checkbox"></td>
            <td class="d1">${yonghuArr[j].id}</td>
            <td class="d1">${yonghuArr[j].name}</td>
             <td class="d1">${yonghuArr[j].principal}</td>
              <td class="d1">${yonghuArr[j].startTime}</td>
               <td class="d1"><span class="iconfont biaoji xiugai">&#xf014f;</span>
               <span class="iconfont biaoji shanchu">&#xe508;</span>
               <span class="iconfont biaoji chakan">&#xe76d;</span></td>
               </tr>`
        )
        num++;
        break;
     }
    alert('确定添加?');
    var popBox = document.getElementById('popBox');
    var popLayer=document.getElementById('popLayer');
    popBox.style.display  = 'none';
    popLayer.style.display = 'none';
  });
  $('#quxiao').click(function (){
    var popBox = document.getElementById('popBox');
    var popLayer=document.getElementById('popLayer');
    popBox.style.display  = 'none';
    popLayer.style.display = 'none';
  })

function closeBox() {
  var popBox = document.getElementById("popBox");
  var popLayer = document.getElementById("popLayer");
  popBox.style.display = "none";
  popLayer.style.display = "none";
}
var popbox1 = document.getElementById('popBox1');
var quedxiu = popbox1.children[13];
var quxiaoxiu = popbox1.children[14];
quedxiu.onclick = function () {
  alert('是否修改?');
  var popBox1 = document.getElementById("popBox1");
  var popLayer = document.getElementById("popLayer");
  popBox1.style.display = "none";
  popLayer.style.display = "none";
}
quxiaoxiu.onclick = function (){
  var popBox1 = document.getElementById("popBox1");
  var popLayer = document.getElementById("popLayer");
  popBox1.style.display = "none";
  popLayer.style.display = "none";
}
function popBox2() {
  var popBox2 = document.getElementById("popBox2");
  var popLayer = document.getElementById("popLayer");
  popBox2.style.display = "block";
  popLayer.style.display = "block";
}
function closeBox2() {
  var popBox2 = document.getElementById("popBox2");
  var popLayer = document.getElementById("popLayer");
  popBox2.style.display = "none";
  popLayer.style.display = "none";
}
var popbox2 = document.getElementById('popBox2');
var quedxiu1 = popbox2.children[13];
var quxiaoxiu1 = popbox2.children[14];
quedxiu1.onclick = function () {
  alert('是否修改?');
  var popBox1 = document.getElementById("popBox2");
  var popLayer = document.getElementById("popLayer");
  popBox1.style.display = "none";
  popLayer.style.display = "none";
}
quxiaoxiu1.onclick = function (){
  var popBox1 = document.getElementById("popBox2");
  var popLayer = document.getElementById("popLayer");
  popBox1.style.display = "none";
  popLayer.style.display = "none";
}
function popBox3() {
  var popBox3 = document.getElementById("popBox3");
  var popLayer = document.getElementById("popLayer");
  popBox3.style.display = "block";
  popLayer.style.display = "block";
}
function closeBox3() {
  var popBox3 = document.getElementById("popBox3");
  var popLayer = document.getElementById("popLayer");
  popBox3.style.display = "none";
  popLayer.style.display = "none";
}
function closeBox1() {
  var popBox3 = document.getElementById("popBox1");
  var popLayer = document.getElementById("popLayer");
  popBox3.style.display = "none";
  popLayer.style.display = "none";
}
var popbox3 = document.getElementById('popBox3');
var quedxiu2 = popbox3.children[13];
var quxiaoxiu2 = popbox3.children[14];
quedxiu2.onclick = function () {
  alert('是否修改?');
  var popBox1 = document.getElementById("popBox3");
  var popLayer = document.getElementById("popLayer");
  popBox1.style.display = "none";
  popLayer.style.display = "none";
}
quxiaoxiu2.onclick = function (){
  var popBox1 = document.getElementById("popBox3");
  var popLayer = document.getElementById("popLayer");
  popBox1.style.display = "none";
  popLayer.style.display = "none";
}
function popBox4() {
  var popBox4 = document.getElementById("popBox4");
  var popLayer = document.getElementById("popLayer");
  popBox4.style.display = "block";
  popLayer.style.display = "block";
}
function closeBox4() {
  var popBox4 = document.getElementById("popBox4");
  var popLayer = document.getElementById("popLayer");
  popBox4.style.display = "none";
  popLayer.style.display = "none";
}
var popbox4 = document.getElementById('popBox4');
var quedxiu3 = popbox4.children[13];
var quxiaoxiu3 = popbox4.children[14];
quedxiu3.onclick = function () {
  alert('是否修改?');
  var popBox1 = document.getElementById("popBox4");
  var popLayer = document.getElementById("popLayer");
  popBox1.style.display = "none";
  popLayer.style.display = "none";
}
quxiaoxiu3.onclick = function (){
  var popBox1 = document.getElementById("popBox4");
  var popLayer = document.getElementById("popLayer");
  popBox1.style.display = "none";
  popLayer.style.display = "none";
}
function popBox5() {
  var popBox5 = document.getElementById("popBox5");
  var popLayer = document.getElementById("popLayer");
  popBox5.style.display = "block";
  popLayer.style.display = "block";
}
function closeBox5() {
  var popBox5 = document.getElementById("popBox5");
  var popLayer = document.getElementById("popLayer");
  popBox5.style.display = "none";
  popLayer.style.display = "none";
}
function popBox6() {
  var popBox5 = document.getElementById("popBox6");
  var popLayer = document.getElementById("popLayer");
  popBox5.style.display = "block";
  popLayer.style.display = "block";
}
function closeBox6() {
  var popBox5 = document.getElementById("popBox6");
  var popLayer = document.getElementById("popLayer");
  popBox5.style.display = "none";
  popLayer.style.display = "none";
}
function popBox7() {
  var popBox5 = document.getElementById("popBox7");
  var popLayer = document.getElementById("popLayer");
  popBox5.style.display = "block";
  popLayer.style.display = "block";
}
function closeBox7() {
  var popBox5 = document.getElementById("popBox7");
  var popLayer = document.getElementById("popLayer");
  popBox5.style.display = "none";
  popLayer.style.display = "none";
}
function popBox8() {
  var popBox5 = document.getElementById("popBox8");
  var popLayer = document.getElementById("popLayer");
  popBox5.style.display = "block";
  popLayer.style.display = "block";
}
function closeBox8() {
  var popBox5 = document.getElementById("popBox8");
  var popLayer = document.getElementById("popLayer");
  popBox5.style.display = "none";
  popLayer.style.display = "none";
}


var piliang = document.getElementById('pilaing');
piliang.onclick =function (){
  var trArr = document.querySelectorAll('#fu>tr')
  var fu = document.getElementById('fu');
  var inputk = document.querySelectorAll('input[type = checkbox]');
  for (var i = 1;i < inputk.length;i++){
    var a = inputk[i];
    if (a.checked == true){
     fu.removeChild(trArr[i-1]);
    }
    for (var j = 0;j< schoolArr.length;j++){
      schoolArr.splice(j,1);
    }
  }
}
se();
function se(){
  $(this).html('');
  for (var i = 0;i<departmentsArr.length;i++){
    var  option = document.createElement('option');
    option.innerText = departmentsArr[i].name;
    $('#bumen').append(option);
  }
  so();
function so(){
  var va ;
  var i;
  $(".s2").change(function (){
    va = $('#bumen option:selected').text();
      $.each(departmentsArr,function (index,item){
        if (item.name == va){
          i = index;
          $('#fuze').html("");
          $('#fuze').append(`
           <option value="">${departmentsArr[i].pople}</option>
          `)
        }
      })
    // var pxb = departmentsArr[index].pople;
  })
  // for (var i = 0; i< pxb.length;i++){
  //   var option = document.createElement('option');
  //   option.innerText = pxb[i]
  //   $('#fuze').append(option);
  //   break;
  // }

}
  var shousuo = $('.shousuo')[0];
shousuo.onclick = function (){
  gettable();
  var shi = $('#shi')[0].selectedIndex;
  if (shi == 0){
    moren();
  }
   // var shi = $('#shi')[0].selectedIndex;
   // if (shi == 0){
   //   gettable();
   // }else {
   //   gettable2();
   // }
}
  moren ();
  function moren (){
    var str = "";
    var num =0;
    for (var  i = 0 ;i<schoolArr.length;i++){
      str +=`<tr id=${'tr' + num}>
           <td class="d1"><input type="checkbox"></td>
            <td class="d1">${schoolArr[i].id}</td>
            <td class="d1">${schoolArr[i].name}</td>
             <td class="d1">${schoolArr[i].principal}</td>
              <td class="d1">${schoolArr[i].startTime}</td>
               <td class="d1"><span class="iconfont biaoji xiugai">&#xf014f;</span>
               <span class="iconfont biaoji shanchu">&#xe508;</span>
               <span class="iconfont biaoji chakan">&#xe76d;</span></td>
               </tr>`
      num++;
    }
    $('#fu').html(str);
  }
function gettable (){
  $('#fu').html("");
 var num =0;
 var who;
 var str = '';
 var val = $("#shi option:selected").text();
 if (val == "成都市"){
   who = "ct001";
 }else  if (val == "绵阳市"){
   who = "ct002";
 }
 for (var i = 0; i< schoolArr.length;i++) {
    if (who ==schoolArr[i].cityNo){
      $("#fu").append(
        `<tr id=${'tr' + num}>
           <td class="d1"><input type="checkbox"></td>
            <td class="d1">${schoolArr[i].id}</td>
            <td class="d1">${schoolArr[i].name}</td>
             <td class="d1">${schoolArr[i].principal}</td>
              <td class="d1">${schoolArr[i].startTime}</td>
               <td class="d1"><span class="iconfont biaoji xiugai">&#xf014f;</span>
               <span class="iconfont biaoji shanchu">&#xe508;</span>
               <span class="iconfont biaoji chakan">&#xe76d;</span></td>
               </tr>`
      )
      num++;
    }
 }
 }
//   function gettable2 (){
//     $('#fu').html("");
//     var num =0;
//     for (var i = 0; i< schoolArr.length;i++) {
//       if ( i == 0){
//         continue;
//       }else if (i == 1){
//         continue;
//       }
//       $("#fu").append(
//         `<tr id=${'tr' + num}>
//            <td class="d1"><input type="checkbox"></td>
//             <td class="d1">${schoolArr[i].id}</td>
//             <td class="d1">${schoolArr[i].name}</td>
//              <td class="d1">${schoolArr[i].principal}</td>
//               <td class="d1">${schoolArr[i].startTime}</td>
//                <td class="d1"><span class="iconfont biaoji xiugai">&#xf014f;</span>
//                <span class="iconfont biaoji shanchu">&#xe508;</span>
//                <span class="iconfont biaoji chakan">&#xe76d;</span></td>
//                </tr>`
//       )
//       num++;
//     }
//
// }
// fy();
//   function fy (){
//     var no = 0;
//     $('.fenye').append(`<ul>
//         <li>&lt;</li>
//         <li>${no+1}</li>
//         <li>&gt;</li>
// </ul>`)
//   }
//修改
$('.father') .on("click",".xiugai",function (){
  popBox1();
  function popBox1(){
    var popBox = document.getElementById("popBox1");
    var popLayer = document.getElementById("popLayer");
    popBox.style.display = "block";
    popLayer.style.display = 'block';
  }
})
//查看
$('.father').on("click",".chakan",function (){
  popBox5();
  function popBox5(){
    var popBox = document.getElementById("popBox5");
    var popLayer = document.getElementById("popLayer");
    popBox.style.display = "block";
    popLayer.style.display = 'block';
  }
})
// 删除
$('#fu').on("click",".shanchu",function (){
for (var i = 0;i< schoolArr.length;i++){
  schoolArr.splice(i,1);
  $(this).parent().parent().remove();
}
})
var duo = $('#biaoge')[0].querySelectorAll('input[type = checkbox]')[0];
duo.onclick = function () {
  var xuanArr = $('#biaoge')[0].querySelectorAll('input[type = checkbox]');
  for (var i = 0; i < xuanArr.length; i++) {
    if (i == 0) {
      continue;
    }
    var a = xuanArr[i];
    if (a.checked == false) {
      a.checked = true;
    } else {
      a.checked = false;
    }
  }
}
}


